package com.meida.module.bus.provider.controller;

import com.meida.module.bus.client.entity.BusSupplier;
import com.meida.module.bus.provider.api.util.PmsApiUtil;
import com.meida.module.bus.provider.service.srmservice.SynchroSrmToPmsService;
import io.swagger.annotations.ApiOperation;
import org.bouncycastle.cms.PasswordRecipientId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.meida.common.mybatis.model.*;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RestController;
import com.meida.common.springmvc.base.BaseController;
import com.meida.module.bus.client.entity.BusRecDeliveryView;
import com.meida.module.bus.provider.service.BusRecDeliReqViewService;


/**
 * 工程师领料申请
 *
 * @author flyme
 * @date 2020-12-01
 */
@RestController
@RequestMapping("/bus/recDeliReq/")
public class BusRecDeliReqController extends BaseController<BusRecDeliReqViewService, BusRecDeliveryView> {
    @Autowired
    private SynchroSrmToPmsService synchroSrmToPmsService;

    @ApiOperation(value = "VIEW-分页列表", notes = "VIEW分页列表")
    @GetMapping(value = "page")
    public ResultBody pageList(@RequestParam(required = false) Map params) {
        return bizService.pageList(params);
    }

    @ApiOperation(value = "VIEW-列表", notes = "VIEW列表")
    @GetMapping(value = "list")
    public ResultBody list(@RequestParam(required = false) Map params) {
        return bizService.listEntityMap(params);
    }

    @ApiOperation(value = "VIEW-添加", notes = "添加VIEW")
    @PostMapping(value = "save")
    public ResultBody save(@RequestBody List<BusRecDeliveryView> busRecDeliveryViews) {
//        List<EntityMap>  listentityMap = JSON.parseArray(params, EntityMap.class);
//        System.out.println(JSONUtil.parseArray(params));
//        List<BusRecDeliveryView> busRecDeliveryViews = JSONUtil.toList(JSONUtil.parseArray(params), BusRecDeliveryView.class);

        bizService.recDeliveryMk(busRecDeliveryViews);
        return ResultBody.msg("提交成功");
    }

    @ApiOperation(value = "VIEW-更新", notes = "更新VIEW")
    @PostMapping(value = "update")
    public ResultBody update(@RequestParam(required = false) Map params) {
        return bizService.edit(params);
    }

    @ApiOperation(value = "VIEW-删除", notes = "删除VIEW")
    @PostMapping(value = "remove")
    public ResultBody remove(@RequestParam(required = false) Map params) {
        return bizService.delete(params);
    }


    @ApiOperation(value = "VIEW-详情", notes = "VIEW详情")
    @GetMapping(value = "get")
    public ResultBody get(@RequestParam(required = false) Map params) {
        return bizService.get(params);
    }

    /**
     * 导出VIEW统计
     *
     * @param params
     * @param request
     * @param response
     */
    @PostMapping(value = "export")
    public void export(@RequestParam(required = false) Map params, HttpServletRequest request, HttpServletResponse response) {
        bizService.export(params, request, response, "VIEW统计", "VIEW统计表");
    }

    @ApiOperation(value = "获取专业分类", notes = "获取专业分类")
    @GetMapping(value = "getMajorPackages")
    public ResultBody getMajorPackages(@RequestParam(required = false) Long projectId, int kind, String majorCode, String packageCode) {
        return bizService.getMaterialPackageMajorList(projectId, kind, majorCode, packageCode);
    }
}
